home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NeXTSTEP 3.1 (Developer) [x86]
/
NeXT Step 3.1 Intel dev.cdr.dmg
/
NextDeveloper
/
Examples
/
AppKit
/
ScrollDoodScroll
/
PostScriptView.m
< prev
next >
Wrap
Text File
|
1992-05-28
|
2KB
|
84 lines
// PostScriptView.m
// By Jayson Adams, NeXT Developer Support Team
// You may freely copy, distribute and reuse the code in this example.
// NeXT disclaims any warranty of any kind, expressed or implied, as to its
// fitness for any particular use.
#import <dpsclient/psops.h>
#import <appkit/NXImage.h>
#import "PostScriptView.h"
@implementation PostScriptView
/* instance methods */
- initFrame:(const NXRect *)frameRect
{
[super initFrame:frameRect];
/*
* create an nximage to hold the PostScript image contained in our MachO
* segment, created by Makefile.preamble; we'll "draw" by compositing the
* resulting bits into ourself. By making the image scalable, we can scale
* the bitmap image by changing our nximage's size
*/
postscriptImage = [[[NXImage alloc] initFromSection:"SampleImage"]
setScalable:YES];
return self;
}
- free
{
[postscriptImage free];
return [super free];
}
- scale:(float)factor
{
NXSize aSize;
/*
* if we resize the nximage, it will reexcute the PostScript
* image with the new scale factor (resulting in a bitmap image that's
* larger or smaller than before)
*/
[postscriptImage getSize:&aSize];
aSize.width *= factor;
aSize.height *= factor;
[postscriptImage setSize:&aSize];
aSize.width = NX_WIDTH(&bounds) * factor;
aSize.height = NX_HEIGHT(&bounds) * factor;
[self sizeTo:aSize.width :aSize.height];
/* show the new image */
[self display];
return self;
}
- drawSelf:(const NXRect *)rects :(int)rectCount
{
/* erase update rect since the nximage might be smaller than our bounds */
PSsetgray(NX_WHITE);
NXRectFill(&(rects[0]));
/*
* copy the bits from the nximage into ourself; note that we need not check
* to see if we're printing since the nximage will do the right thing (i.e.
* spit out PostScript) if we are
*/
[postscriptImage composite:NX_SOVER
fromRect:&(rects[0])
toPoint:&(rects[0].origin)];
return self;
}
@end